// 从pinia中导入defineStore方法
import {
	defineStore
} from 'pinia'
import {
	ref
} from 'vue'


// 导出
export const userStore = defineStore("user", () => {
	// 定于状态变量
	// 定义token令牌
	let token = ref("")
	// 已登录用户信息
	let userInfo = ref({})
	// 登陆状态
	let isLogin = ref(false)
	// 定义动作

	function addUserInfo(id, username, email, mobile, token) {
		this.userInfo.id = id
		this.userInfo.username = username;
		this.userInfo.email = email;
		this.userInfo.mobile = mobile;
		this.token = token
		this.isLogin = true

	}

	// 清除用户信息
	function clearUserInfo() {
		this.userInfo = {}
		this.isLogin = false
		this.token = ""
	}

	
	
	
	return {
		token,
		userInfo,
		isLogin,
		addUserInfo,
		clearUserInfo
	}
})